import logging
from redis import StrictRedis
from datetime import timedelta

# 设置配置信息
class Config(object):
    # debug模式/
    DEBUG = True
    SECRET_KEY = "khdfjalj"
    # 数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost:3306/info14"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    # session配置
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=31)
    # 设置日志级别
    LEVEL_NAME = logging.DEBUG
# 开发阶段配置
class DevelopConfig(Config):
    pass
# 生产阶段配置
class ProdutConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR
# 测试阶段配置
class TestConfig(Config):
    TESTING = True
# 配置信息的访问入口
config_dict = {
    "develop":DevelopConfig,
    "product":ProdutConfig,
    "test":TestConfig
}

